package cn.sc.allinpay.allfavour.base.activity;

import android.os.Bundle;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;

import cn.pai.mvp.presenter.IPresenter;
import cn.pai.mvp.view.IView;
import cn.pai.mvp.view.PaiActivity;
import cn.sc.allinpay.allfavour.R;

/**
 * activity基类
 * author：pany
 * on 2017/12/1 11:14
 */
public abstract class BaseActivity<V extends IView, P extends IPresenter<V>> extends PaiActivity<V, P> {

    @Override
    protected void layoutView(Bundle savedInstanceState) {
        layoutTitle();
        layoutContent(savedInstanceState);
    }

    /**
     * 设置title
     */
    private void layoutTitle() {
        View top = find(R.id.top);
        if (top != null) {
            AppCompatTextView topTitle = find(R.id.topTitle);
            AppCompatTextView topLeft = find(R.id.topLeft);
            topLeft.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    onBackPressed();
                }
            });
            AppCompatTextView topRight = find(R.id.topRight);
            layoutTitle(top, topLeft, topTitle, topRight);
        }
    }

    protected void layoutTitle(View top, AppCompatTextView left, AppCompatTextView title,
                               AppCompatTextView right) {
    }

    protected abstract void layoutContent(Bundle savedInstanceState);
}
